package com.clps.digital.dao.impl;


import com.clps.digital.dao.OrderDao;
import com.clps.digital.model.entity.Orders;
import com.clps.myssm.basedao.BaseDAO;

import java.util.Collections;
import java.util.List;

/**
 * @Author: 小炎子
 * @Date: 2024/9/3 下午2:38
 * @Description: 订单dao实现层
 **/
public class OrderDaoImpl extends BaseDAO<Orders> implements OrderDao {


    /*
    * @Author 小炎子
    * @Description 买入的订单创建
    * @Date 下午2:58 2024/9/3
    */
    @Override
    public void buysave(Orders orders) {
        insertOrUpdate("INSERT INTO dbo.[orders] ([buyId], [currencyId], [quantity], [price]) VALUES (?, ?, ?, ?)",orders.getBuyId(),orders.getCurrencyId(),orders.getQuantity(),orders.getPrice());
    }

    /*
     * @Author 小炎子
     * @Description 卖出的订单创建
     * @Date 下午2:58 2024/9/3
     */
    @Override
    public void sellsave(Orders orders) {
        insertOrUpdate("INSERT INTO dbo.[orders] ([soldId], [currencyId], [quantity], [price]) VALUES (?, ?, ?, ?)",orders.getSoldId(),orders.getCurrencyId(),orders.getQuantity(),orders.getPrice());

    }

    /*
    * @Author 小炎子
    * @Description 获取当前用户的订单列表
    * @Date 下午3:01 2024/9/3
    */
    @Override
    public List<Orders> getOdersList(Long userId) {
        return selectList("SELECT * from dbo.[orders] where [buyId] = ? or [soldId] = ?", userId,userId);
    }

    @Override
    public List<Orders> getAllOrdersList() {
        return selectList("SELECT * from dbo.[orders]");
    }


}
